FROM maven:3.6.0-jdk-8-alpine

LABEL maintainer="chenwenlong <chenwenlong@epweike.com>"

RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

COPY settings.xml /usr/share/maven/ref/
COPY pom.xml /tmp

RUN set -ex && \
    apk add --no-cache --update --virtual .fetch-deps git && \
    mkdir -p /data/datax && \
    git clone  --branch master --depth 1 https://github.com/alibaba/DataX.git /data/datax && \
    cp /tmp/pom.xml /data/datax/otsstreamreader/ && \
    apk del .fetch-deps && \
    cd /data/datax && \
    mvn -U clean package assembly:assembly -Dmaven.test.skip=true && \
    mv /data/datax/target/datax/datax/ /opt/ && \
    rm -rf /data && \
    rm  -rf /root/.m2

ENTRYPOINT [ "/opt/datax/bin/datax.py" ]

CMD [ '--help' ]